# coding=utf-8
import ast

with open('dzzzex.log', 'r', encoding='UTF-8') as f:
    txts=f.readlines()
    for i in range(len(txts)):
        try:
            if txts[i].find('submitLicense(173)') > 0:
                dt = ast.literal_eval(
                    txts[i - 1].split('submitLicense:')[1].replace('$', 'M').replace('false', 'False').replace('true',
                                                                                                               'True'))
                children = dt.get("children")[0].get('content')[0].get('document').get('content')[0].get('children')[
                    0].get('descendants')
              #  print(children)
                certificateHolder=''
                certificateHolderCode=''
                for c in children:
                    a = c.get('qualifiedName')
                    if a != None:
                        if a == 'CertificateHolder':
                            certificateHolder=c.get('value')
                        elif a == 'CertificateHolderCode':
                            certificateHolderCode=c.get('value')
                print(txts[i - 4].split('|')[1].strip().split(':')[1].strip(),
                      txts[i - 3].split('|')[1].strip().split(':')[1].strip(),
                      txts[i - 2].split('|')[1].strip().split(':')[1].strip(), txts[i].split('|')[1].strip(), certificateHolder, certificateHolderCode, sep='\t')
        except:
            str=10


          #  print(txts[i-1].split('submitLicense:')[1])

           #  print(eval(''''''))
          # print(eval(txts[i - 1].split('submitLicense:')[1]))

            #print(eval(txts[i-1].split('submitLicense:')[1]))
        ##    print(txts[i - 4].split('|')[1].strip().split(':')[1].strip(), txts[i - 3].split('|')[1].strip().split(':')[1].strip(), txts[i - 2].split('|')[1].strip().split(':')[1].strip(), txts[i].split('|')[1].strip(), sep='\t')



